import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router = new Router({
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/login',
      name: 'login',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/login/index.vue'),
      meta: {
        title: '登录注册'
      }
    },
    {
      path: '/',
      name: 'index',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/index/index.vue'),
      meta: {
        title: '管理端首页'
      }
    },
    {
      path: '/stationList',
      name: 'stationList',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/stationList/index.vue'),
      meta: {
        title: '充电桩'
      }
    },
    {
      path: '/adminStation',
      name: 'adminStation',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/adminStation/index.vue'),
      meta: {
        title: '充电桩'
      }
    },
    {
      path: '/feedbackList',
      name: 'feedbackList',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/feedbackList/index.vue'),
      meta: {
        title: '故障反馈'
      }
    },
    {
      path: '/feedbackDetail',
      name: 'feedbackDetail',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/feedbackDetail/index.vue'),
      meta: {
        title: '故障反馈'
      }
    },
    {
      path: '/searchStation',
      name: 'searchStation',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/searchStation/index.vue'),
      meta: {
        title: '筛选充电桩'
      }
    },
    {
      path: '/record',
      name: 'record',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/record/index.vue'),
      meta: {
        title: '充电记录'
      }
    },
    {
      path: '/count',
      name: 'count',
      component: () => import(/* webpackChunkName: "about" */ './views/admin/count/index.vue'),
      meta: {
        title: '报表统计'
      }
    }
  ]
})

// 全局路由守卫
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});

export default router;

